package admin

import (
	"github.com/gin-gonic/gin"
	"syudy/Controller/admin"
	"syudy/Middleware"
)

func LoginRoute(c *gin.Engine) {
	//加载鉴权中间件，不允许没有session的用户访问所有页面，除了login、doLogin、captcha页面
	adminRouters := c.Group("/admin", Middleware.InitAdminAuthMiddleware)
	{
		c.Static("/static", "./static/")
		c.LoadHTMLGlob("templates/**/**/*")

		//admin页面
		adminRouters.GET("/", admin.MainController{}.Index)
		adminRouters.GET("/welcome", admin.MainController{}.Welcome)

		//登录页面及方法
		adminRouters.GET("/login", admin.LoginController{}.Index)
		adminRouters.GET("/captcha", admin.LoginController{}.Captcha)
		adminRouters.GET("/loginOut", admin.LoginController{}.LoginOut)
		adminRouters.POST("/doLogin", admin.LoginController{}.DoLogin)

		//管理员页面及方法
		adminRouters.GET("/manager", admin.ManagerController{}.Index)
		adminRouters.GET("/manager/add", admin.ManagerController{}.Add)
		adminRouters.POST("/manager/doAdd", admin.ManagerController{}.DoAdd)
		adminRouters.GET("/manager/edit", admin.ManagerController{}.Edit)
		adminRouters.GET("/manager/delete", admin.ManagerController{}.Delete)

		//轮播页面及方法
		adminRouters.GET("/focus", admin.FocusController{}.Index)
		adminRouters.GET("/focus/add", admin.FocusController{}.Add)
		adminRouters.GET("/focus/edit", admin.FocusController{}.Edit)
		adminRouters.GET("/focus/delete", admin.FocusController{}.Delete)

		//role页面及方法
		adminRouters.GET("/role", admin.RoleController{}.Index)
		adminRouters.GET("/role/add", admin.RoleController{}.Add)
		adminRouters.POST("/role/doAdd", admin.RoleController{}.DoAdd)
		adminRouters.GET("/role/edit", admin.RoleController{}.Edit)
		adminRouters.POST("/role/doEdit", admin.RoleController{}.DoEdit)
		adminRouters.GET("/role/delete", admin.RoleController{}.Delete)

		//权限页面及方法
		adminRouters.GET("/access", admin.AccessController{}.Index)
		adminRouters.GET("/access/add", admin.AccessController{}.Add)
		adminRouters.POST("/access/doAdd", admin.AccessController{}.DoAdd)

	}
}
